<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>      
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/Jangdolbaeng2/css/bootstrap.min.css" rel="stylesheet">
<link href="/Jangdolbaeng2/css/customer/common.css" rel="stylesheet">
<title>우편번호검색</title>
<script type="text/javascript">
function formCheck()
{
	var searchText = document.getElementById('searchText');
	
	if(searchText.value.length < 2 || searchText.value.length > 10)
	{
		alert('키워드를 2~10자로 입력하세요');
		return false;
	}
	
	return true;
}

function selectZipcode(zip, add)
{
	opener.document.getElementById("zipcode").value = zip;
	opener.document.getElementById("address1").value = add;
	this.close();
} 

</script>
</head>
<body>
<h3 align="center" style="margin-top: 50px; margin-bottom: 20px;"><span class="glyphicon glyphicon-envelope"></span> <span style="font-family: anew">우편번호검색</span></h3>
<center>
<s:form action="listZipcode" theme="simple" onsubmit="return formCheck()">
	<s:textfield name="searchText" id="searchText" placeholder="검색할 우편번호 입력"/>
	<s:submit value="검색" />
</s:form>	 
<br><br>


<s:if test="zipcodelist != null">
	<s:if test="zipcodelist.size() == 0">
		<script>alert('우편번호가 없습니다.')</script>
	</s:if>
</s:if>	

<table border="1">
<s:iterator value="zipcodelist" status="status">
<s:set var="address" value="%{area1 + ' ' + area2 + ' ' + area3 + ' ' + area4}" />
<tr>
<td>	
<s:property value="#status.index" />
</td>
<td>
<s:property value="zipcode"/>
<s:property value="area1" />
<s:property value="area2"/>
<s:property value="area3"/>
<s:property value="area4"/>
</td>
<td>
<a href="javascript:selectZipcode('<s:property value="zipcode" />', '<s:property value="address" />')">선택</a>
</td>
</tr>

</s:iterator>
</table>
</center>
</body>
</html>



